package edu.zhuravlev.trainingbot;

import edu.zhuravlev.trainingbot.conifg.BotConfig;
import edu.zhuravlev.trainingbot.dispatcher.BotDispatcher;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsumer;
import org.telegram.telegrambots.longpolling.starter.AfterBotRegistration;
import org.telegram.telegrambots.longpolling.starter.SpringLongPollingBot;


@Slf4j
@SpringBootApplication
@RequiredArgsConstructor
@ConfigurationPropertiesScan
@EnableConfigurationProperties
public class TrainingBotApplication implements SpringLongPollingBot {

    private final BotConfig botConfig;

    private final BotDispatcher dispatcher;


    public static void main(String[] args) {
        SpringApplication.run(TrainingBotApplication.class, args);
    }

    @Override
    public String getBotToken() {
        return botConfig.getToken();
    }

    @Override
    public LongPollingUpdateConsumer getUpdatesConsumer() {
        return dispatcher;
    }

    @AfterBotRegistration
    public void onRegister() {
        log.info("\n" +
                "████████╗██████╗░░█████╗░██╗███╗░░██╗██╗███╗░░██╗░██████╗░  ██████╗░░█████╗░████████╗\n" +
                "╚══██╔══╝██╔══██╗██╔══██╗██║████╗░██║██║████╗░██║██╔════╝░  ██╔══██╗██╔══██╗╚══██╔══╝\n" +
                "░░░██║░░░██████╔╝███████║██║██╔██╗██║██║██╔██╗██║██║░░██╗░  ██████╦╝██║░░██║░░░██║░░░\n" +
                "░░░██║░░░██╔══██╗██╔══██║██║██║╚████║██║██║╚████║██║░░╚██╗  ██╔══██╗██║░░██║░░░██║░░░\n" +
                "░░░██║░░░██║░░██║██║░░██║██║██║░╚███║██║██║░╚███║╚██████╔╝  ██████╦╝╚█████╔╝░░░██║░░░\n" +
                "░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝╚═╝░░╚══╝╚═╝╚═╝░░╚══╝░╚═════╝░  ╚═════╝░░╚════╝░░░░╚═╝░░░");
    }
}
